<!DOCTYPE html>
<html>
<head>
    <title>注册渠道来源</title>
    <#include "/header.html">
</head>
<style>
    .el-table td, .el-table th {
        padding: 4px 0;
    }
    .el-table th {
        color: #0a8ddf;
    }
    .el-table .cell, .el-table th {
        padding-right: 4px;
        padding-left: 4px;
    }

    div.el-col .el-col-12 {
        padding: 4px;
    }

    .el-form-item {
        margin-bottom: 20px;
    }
</style>
<body>
<div id="rrapp" v-cloak>
    <!--查询-->
    <div>
        <el-form :inline="true" class="demo-form-inline" size="small">
            <el-form-item>
                <el-input type="text" v-model="q.sourceName" placeholder="渠道名关键字"></el-input>
            </el-form-item>
            <el-form-item>
                <el-select v-model="q.sendCoupon" style="width: 150px;">
                    <el-option label="发券状态" value=""></el-option>
                    <el-option label="发券" :value="1"></el-option>
                    <el-option label="不发券" :value="0"></el-option>
                </el-select>
            </el-form-item>
            <el-button type="primary" @click="query" icon="el-icon-search" size="small" plain>查询</el-button>
            <el-button type="primary" @click="reset" size="small" plain>重置</el-button>&nbsp;&nbsp;&nbsp;
            <el-button size="small" type="success" @click="add">新 增</el-button>&nbsp;&nbsp;&nbsp;
            <!--<el-button size="small" type="danger" icon="el-icon-delete" @click="handleAllDelete">多选删除</el-button>-->
        </el-form>
    </div>
    <!--首页-->
    <template>
        <el-table border ref="singleTable" :data="userRegisterSource" highlight-current-row style="width: 100%">
            <el-table-column type="index" label="序号" :index="indexMethod" width="55" align="center"></el-table-column>
            <el-table-column property="sourceName" label="渠道名称" width="120px;" align="center"></el-table-column>
            <el-table-column property="sourceKey" label="渠道key" align="center" width="120px;"></el-table-column>
            <el-table-column property="sourceUrl" label="渠道URL" align="center"></el-table-column>
            <el-table-column property="startTime" label="起始时间" align="center"></el-table-column>
            <el-table-column property="endTime" label="结束时间" align="center"></el-table-column>
            <el-table-column property="sendCoupon" label="是否发券" width="100px;" align="center">
                <template slot-scope="scope">
                    <span style="color: #2ac845" v-show="scope.row.sendCoupon ==true">发券</span>
                    <span style="color: red" v-show="scope.row.sendCoupon ==false">不发券</span>
                </template>
            </el-table-column>
            <el-table-column property="orderCouponIds" label="注册券ids" align="center"></el-table-column>
            <el-table-column property="registerCouponIds" label="首单券ids" align="center"></el-table-column>
            <el-table-column property="createName" label="创建人" align="center"></el-table-column>
            <el-table-column property="createTime" label="创建时间" align="center"></el-table-column>
            <el-table-column label="操作" align="center">
                <template slot-scope="scope">
                    <el-button size="mini" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
                    <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
        <br>
        <div class="block" align="center">
            <el-pagination
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :current-page="page.currentPage"
                    :page-sizes="page.pageSizes"
                    :page-size="page.pageSize"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="page.total">
            </el-pagination>
        </div>
    </template>

    <!--新增编辑-->
    <el-dialog :title="title" :visible.sync="RegisterVisible" width="850px" :before-close="closeChangeMachie">
        <el-form :model="RegisterFrom" ref="RegisterFrom" label-width="100px" center>
            <el-row>
                <el-col :span="12">
                    <el-form-item v-show="RegisterFrom.sourceId ==null" prop="sourceName" label="渠道名称"
                                  :rules="[{ required: true, message: '请输入渠道名称', trigger: 'blur'}]">
                        <el-input v-model="RegisterFrom.sourceName" placeholder="请输入渠道名称"></el-input>
                    </el-form-item>
                    <el-form-item v-show="RegisterFrom.sourceId !=null" label="渠道名称">
                        <el-input v-model="RegisterFrom.sourceName" :disabled="true"></el-input>
                    </el-form-item>
                    <el-form-item prop="sourceUrl" label="渠道URL"
                                  :rules="[{ required: true, message: '请输入渠道名称', trigger: 'blur'}]">
                        <el-input v-model="RegisterFrom.sourceUrl" placeholder="请输入渠道URL"></el-input>
                    </el-form-item>
                    <el-form-item prop="startTime" label="起始时间">
                        <el-date-picker v-model="RegisterFrom.startTime" type="datetime"
                                        value-format="yyyy-MM-dd HH:mm:ss" style="width: 305px;"
                                        placeholder="选择日期时间" default-time="00:00:00">
                        </el-date-picker>
                    </el-form-item>
                    <el-form-item prop="orderCouponIds" label="首单券ids">
                        <el-select v-model="RegisterFrom.orderCouponIds" multiple placeholder="请选择"
                                   style="width: 305px;">
                            <el-option v-for="item in couponList"
                                       :key="item.id"
                                       :label="item.name.substring(0,20)"
                                       :value="item.id">
                            </el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item prop="sourceKey" label="渠道key"
                                  :rules="[{ required: true, message: '请输入渠道名称', trigger: 'blur'}]">
                        <el-input v-model="RegisterFrom.sourceKey" placeholder="请输入渠道key"></el-input>
                    </el-form-item>
                    <el-form-item label="是否发券">
                        <el-select v-model="RegisterFrom.sendCoupon" style="width: 305px;">
                            <el-option label="发券" :value="true"></el-option>
                            <el-option label="不发券" :value="false"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item prop="endTime" label="结束时间">
                        <el-date-picker v-model="RegisterFrom.endTime" type="datetime"
                                        value-format="yyyy-MM-dd HH:mm:ss" style="width: 305px;"
                                        placeholder="选择日期时间" default-time="23:59:59">
                        </el-date-picker>
                    </el-form-item>
                    <el-form-item prop="registerCouponIds" label="注册券ids">
                        <el-select v-model="RegisterFrom.registerCouponIds" multiple placeholder="请选择"
                                   style="width: 305px;">
                            <el-option v-for="it in couponList"
                                       :key="it.id"
                                       :label="it.name.substring(0,20)"
                                       :value="it.id">
                            </el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-form-item style="margin-left: 520px;">
                <el-button type="primary" @click="submitFrom('RegisterFrom')" size="small" plain>提交</el-button>
                <el-button type="primary" v-show="RegisterFrom.sourceId==null" @click="resetForm('RegisterFrom')"
                           size="small" plain>重置
                </el-button>
                <el-button type="primary" v-show="RegisterFrom.sourceId !=null" @click="closeChangeMachie" size="small"
                           plain>取消
                </el-button>
            </el-form-item>
        </el-form>
    </el-dialog>
    <!--新增编辑结束-->
</div>

<script src="${request.contextPath}/statics/js/modules/userRegisterSource/userregistersource.js?_${.now?long}"></script>
</body>
</html>